﻿using UnityEngine;
using System.Collections;

public class RetraitChaine : MonoBehaviour {
	
	public GameObject chaine;
	public float speed;
	private float positionCourante;
	private float positionDebut;
	public float positionMax;
	public float mouvementChaine;
	public static float positionFin;
	
	void Start () {
		positionDebut = transform.position.y;
	}

	void FixedUpdate () {
		
		positionCourante = transform.position.y;
		
		if (positionCourante > positionMax && HitOrbe.moving) {
			if(positionCourante > positionDebut-mouvementChaine) {
				transform.position += new Vector3 (0, speed * Time.deltaTime* -1, 0 );
			}
			else{ 
				positionDebut = positionCourante; 
				HitOrbe.moving = false;
				positionFin = positionCourante;

			}
		}
	}

}
